import MapImageLayer from "@arcgis/core/layers/MapImageLayer";
import FeatureLayer from "@arcgis/core/layers/FeatureLayer";
const getters = {
  sidebar: (state) => state.app.sidebar,
  size: (state) => state.app.size,
  device: (state) => state.app.device,
  dict: (state) => state.dict.dict,
  visitedViews: (state) => state.tagsView.visitedViews,
  cachedViews: (state) => state.tagsView.cachedViews,
  token: (state) => state.user.token,
  avatar: (state) => state.user.avatar,
  name: (state) => state.user.name,
  nickName:(state)=>state.user.nickName,
  phonenumber:(state)=>state.user.phonenumber,
  deptId:(state)=>state.user.deptId,
  introduction: (state) => state.user.introduction,
  roles: (state) => state.user.roles,
  dataScope:(state)=>state.user.dataScope,
  permissions: (state) => state.user.permissions,
  permission_routes: (state) => state.permission.routes,
  topbarRouters: (state) => state.permission.topbarRouters,
  defaultRoutes: (state) => state.permission.defaultRoutes,
  sidebarRouters: (state) => state.permission.sidebarRouters,
  hightlights: (state) => state.map.hightlights,
  xzqhFeatureLayer: (state) => {
    console.log("get xzqhFeatureLayer");
    if (state.xzqhFeatureLayer == null)
      state.xzqhFeatureLayer = new FeatureLayer({
        url: window.mapConfig.xzqhLayer.url,
        id: window.mapConfig.xzqhLayer.id,
        // opacity: window.mapConfig.operationLayers.mapservers["shequ"].opacity,
        // popupEnabled:
        //   window.mapConfig.operationLayers.mapservers["shequ"].popupEnabled,
        // visible: window.mapConfig.operationLayers.mapservers["shequ"].visible,
        symbol: window.mapConfig.xzqhLayer.symbol,
      });
    return state.xzqhFeatureLayer;
  },
  greenlandLayers: (state) => {
    console.log("get greenlandLayers" + state.greenlandLayers);
    if (state.greenlandLayers == null)
      state.greenlandLayers = new MapImageLayer({
        title: window.mapConfig.operationLayers.mapservers["greenland"].title,
        url: window.mapConfig.operationLayers.mapservers["greenland"].url,
        id: window.mapConfig.operationLayers.mapservers["greenland"].id,
        // opacity: window.mapConfig.operationLayers.mapservers["dianzld"].opacity,
        // popupEnabled:
        //   window.mapConfig.operationLayers.mapservers["dianzld"].popupEnabled,
        // visible: window.mapConfig.operationLayers.mapservers["dianzld"].visible,
      });
    return state.greenlandLayers;
  },
  dianzldFeatureLayer: (state) => {
    console.log("get dianzldFeatureLayer" + state.dianzldFeatureLayer);
    if (state.dianzldFeatureLayer == null)
      state.dianzldFeatureLayer = new FeatureLayer({
        title: window.mapConfig.operationLayers.mapservers["dianzld"].title,
        url: window.mapConfig.operationLayers.mapservers["dianzld"].url,
        id: window.mapConfig.operationLayers.mapservers["dianzld"].id,
        opacity: window.mapConfig.operationLayers.mapservers["dianzld"].opacity,
        popupEnabled:
          window.mapConfig.operationLayers.mapservers["dianzld"].popupEnabled,
        visible: window.mapConfig.operationLayers.mapservers["dianzld"].visible,
        minScale:
          window.mapConfig.operationLayers.mapservers["dianzld"].minScale,
        maxScale:
          window.mapConfig.operationLayers.mapservers["dianzld"].maxScale,
      });
    return state.dianzldFeatureLayer.clone();
  },
  qitaldFeatureLayer: (state) => {
    console.log("get qitaldFeatureLayer" + state.qitaldFeatureLayer);

    if (state.qitaldFeatureLayer == null)
      state.qitaldFeatureLayer = new FeatureLayer({
        title: window.mapConfig.operationLayers.mapservers["qitald"].title,
        url: window.mapConfig.operationLayers.mapservers["qitald"].url,
        id: window.mapConfig.operationLayers.mapservers["qitald"].id,
        opacity: window.mapConfig.operationLayers.mapservers["qitald"].opacity,
        popupEnabled:
          window.mapConfig.operationLayers.mapservers["qitald"].popupEnabled,
        visible: window.mapConfig.operationLayers.mapservers["qitald"].visible,
        minScale:
          window.mapConfig.operationLayers.mapservers["qitald"].minScale,
        maxScale:
          window.mapConfig.operationLayers.mapservers["qitald"].maxScale,
      });
    return state.qitaldFeatureLayer.clone();
  },
  roadldFeatureLayer: (state) => {
    console.log("get roadldFeatureLayer" + state.roadldFeatureLayer);

    if (state.roadldFeatureLayer == null)
      state.roadldFeatureLayer = new FeatureLayer({
        title: window.mapConfig.operationLayers.mapservers["roadld"].title,
        url: window.mapConfig.operationLayers.mapservers["roadld"].url,
        id: window.mapConfig.operationLayers.mapservers["roadld"].id,
        opacity: window.mapConfig.operationLayers.mapservers["roadld"].opacity,
        popupEnabled:
          window.mapConfig.operationLayers.mapservers["roadld"].popupEnabled,
        visible: window.mapConfig.operationLayers.mapservers["roadld"].visible,
        minScale:
          window.mapConfig.operationLayers.mapservers["roadld"].minScale,
        maxScale:
          window.mapConfig.operationLayers.mapservers["roadld"].maxScale,
      });
    return state.roadldFeatureLayer.clone();
  },
  gusmmFeatureLayer: (state) => {
    console.log("get gusmmFeatureLayer");

    if (state.gusmmFeatureLayer == null)
      state.gusmmFeatureLayer = new FeatureLayer({
        title: window.mapConfig.operationLayers.mapservers["gusmm"].title,
        url: window.mapConfig.operationLayers.mapservers["gusmm"].url,
        id: window.mapConfig.operationLayers.mapservers["gusmm"].id,
        opacity: window.mapConfig.operationLayers.mapservers["gusmm"].opacity,
        popupEnabled:
          window.mapConfig.operationLayers.mapservers["gusmm"].popupEnabled,
        visible: window.mapConfig.operationLayers.mapservers["gusmm"].visible,
      });
    return state.gusmmFeatureLayer.clone();
  },
  shequFeatureLayer: (state) => {
    console.log("get shequFeatureLayer");
    if (state.shequFeatureLayer == null)
      state.shequFeatureLayer = new FeatureLayer({
        title: window.mapConfig.operationLayers.mapservers["shequ"].title,
        url: window.mapConfig.operationLayers.mapservers["shequ"].url,
        id: window.mapConfig.operationLayers.mapservers["shequ"].id,
        opacity: window.mapConfig.operationLayers.mapservers["shequ"].opacity,
        popupEnabled:
          window.mapConfig.operationLayers.mapservers["shequ"].popupEnabled,
        visible: window.mapConfig.operationLayers.mapservers["shequ"].visible,
      });
    return state.shequFeatureLayer;
  },
};
export default getters;
